package com.mm.dss.demo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mm.dss.demo.base.BaseActivity;
import com.mm.dss.demo.tools.SharedPreferencedUtils;
import com.mm.dss.demo.view.LogoutDialog;


public class MineActivity extends BaseActivity {
    TextView username;//用户id
    TextView rusername;//真正的用户名
    TextView txt_title;
    RelativeLayout layout_back;
   TextView btn_out;//
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mine);
        intview();
    }

    private void intview() {
        txt_title= (TextView) findViewById(R.id.txt_title);
        layout_back= (RelativeLayout) findViewById(R.id.layout_back);
        layout_back.setVisibility(View.VISIBLE);
        txt_title.setText("个人中心");
        btn_out= (TextView) findViewById(R.id.btn_out);
        username= (TextView) findViewById(R.id.username);
        rusername= (TextView) findViewById(R.id.rusername);
        username.setText(SharedPreferencedUtils.getString(MineActivity.this,"username"));
        rusername.setText(SharedPreferencedUtils.getString(MineActivity.this,"realname"));
    }

    public void  onclick(View view){
        switch (view.getId()){
            case R.id.layout_back:
                finish();
                break;
            case R.id.btn_out:

                //退出登录
                LogoutDialog dialog = new LogoutDialog(this);
                dialog.setTltMsg("是否退出登录");
                dialog.setNoStr("取消");
                dialog.setYesStr("退出");
                dialog.setYesTextColor(R.color.logout);
               dialog.setNoOnclickListener(v -> {
                   dialog.dismiss();
               });
                dialog.setYesOnclickListener(v -> {
                    dialog.dismiss();
                    SharedPreferencedUtils.setString(MineActivity.this,"username",null);
                    SharedPreferencedUtils.setString(MineActivity.this,"realname",null);
                    SharedPreferencedUtils.setString(MineActivity.this,"Level",null);
                    startActivity(new Intent(MineActivity.this, SLoginActivity.class));
                    ZhuMainActivity.activity.finish();
                    finish();
                });
                dialog.show();



                break;
        }

    }
}
